package org.crazyit.cloud;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;

/***
 * Apache的一个工具，用来发请求的
 */
public class TestClient {
    public static void main(String[] args) throws IOException {
        //创建默认的HttpClient
        CloseableHttpClient httpClient = HttpClients.createDefault();
        //调用6次服务并输出结果
        for(int i=0;i<6;i++){
            //调用get方法请求服务
            HttpGet httpget = new HttpGet("http://127.0.0.1:9000/router");
            //获得响应
            HttpResponse response = httpClient.execute(httpget);
            //根据 响应解析出字符串
            System.out.println(EntityUtils.toString(response.getEntity()));
        }
    }
}
